package com.eddie.interator;

import java.util.Iterator;
import java.util.List;

/**
 * 在这里Java提供的Iterator就是抽象迭代器，本类是迭代器的实现
 * @author Eddie
 * @date 2022/08/03 20:32
 **/
public class InfoCollegeIterator implements Iterator<Object> {

    //这里我们需要Department 是以怎样的方式存放
    private List<Department> departments;
    //遍历的位置
    private int index = -1;

    public InfoCollegeIterator(List<Department> departments) {
        this.departments = departments;
    }

    @Override
    public boolean hasNext() {
        if(index >= departments.size()-1) {
            return false;
        }
        index++;
        return true;
    }

    @Override
    public Object next() {
        return departments.get(index);
    }

    //删除的方法默认空实现
    public void remove() {

    }
}
